package com.chixing.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public Queue remindToReturnTheCarQueue() {
        return new Queue("RemindToReturnTheCar",true);
    }
    @Bean
    DirectExchange remindToReturnTheCarExchange(){
        return new DirectExchange("RemindToReturnTheCarExchange",true,false);
    }
    @Bean
    Binding bindingRemindToReturnTheCarExchange(){
        return BindingBuilder.bind(remindToReturnTheCarQueue()).to(remindToReturnTheCarExchange()).with("RemindToReturnTheCarRouting");
    }


    @Bean
    public Queue remindFirstToReturnTheCarQueue() {
        return new Queue("RemindFirstToReturnTheCar",true);
    }
    @Bean
    DirectExchange remindFirstToReturnTheCarExchange(){
        return new DirectExchange("RemindFirstToReturnTheCarExchange",true,false);
    }
    @Bean
    Binding bindingRemindFirstToReturnTheCarExchange(){
        return BindingBuilder.bind(remindFirstToReturnTheCarQueue()).to(remindFirstToReturnTheCarExchange()).with("RemindFirstToReturnTheCarRouting");
    }

    //订单成功支付队列
    @Bean
    public Queue orderSuccessPayQueue(){
        return new Queue("orderSuccessPayQueue",true);
    }
    @Bean
    DirectExchange orderSuccessPayExchange(){
        return new DirectExchange("orderSuccessPayExchange",true,false);
    }
    @Bean
    Binding bindingOrderSuccessPayExchange(){
        return BindingBuilder.bind(orderSuccessPayQueue())
                .to(orderSuccessPayExchange())
                .with("orderSuccessPayRouting");
    }

    //订单未成功支付队列
    @Bean
    public Queue orderFailPayQueue(){
        return new Queue("orderFailPayQueue",true);
    }
    @Bean
    DirectExchange orderFailPayExchange(){
        return new DirectExchange("orderFailPayExchange",true,false);
    }
    @Bean
    Binding bindingOrderFailPayExchange(){
        return BindingBuilder.bind(orderFailPayQueue())
                .to(orderFailPayExchange())
                .with("orderFailPayRouting");
    }

    //库存减一和销量加一队列
    @Bean
    public Queue updateStoreCarQueue(){
        return new Queue("updateStoreCarQueue",true);
    }
    @Bean
    public DirectExchange updateStoreCarExchange(){
        return new DirectExchange("updateStoreCarExchange",true,true);
    }
    @Bean
    public Binding bindingUpdateStoreCarExchange(){
        return BindingBuilder.bind(updateStoreCarQueue()).to(updateStoreCarExchange()).with("updateStoreCarRouting");
    }

    //添加流水队列
    @Bean
    public Queue insertFlowQueue(){
        return new Queue("insertFlowQueue",true);
    }
    @Bean
    public DirectExchange insertFlowExchange(){
        return new DirectExchange("insertFlowExchange",true,false);
    }
    @Bean
    public Binding bindingInsertFlowExchange(){
        return BindingBuilder.bind(insertFlowQueue())
                .to(insertFlowExchange()).with("insertFlowRouting");
    }
}